#!/usr/bin/env python
# coding: utf-8

from __future__ import print_function
from lab6 import *
import timeit


par_check('(())')
par_check('(((())))(())(()(((()))))')

par_check('')

par_check(')')
par_check('(()))')
par_check('(')

pseq = ['(())',
        '(((())))(())(()(((()))))',
        '',
        ')',
        '(()))',
        '(']

t = timeit.Timer('par_check(x)', 'from {} import par_check, x'.format(__name__))
for x in pseq:
    print('"{1:s}"{2}{0:.7f}'.format(t.timeit(number=1000), x, ' ' * (3 + 26 - len(x))))

for exp in xrange(4, 12):
    l = 2 ** exp
    result = 0.0
    for n in xrange(100):
        x = ''.join([p for i in xrange(l / 2) for p in random.choice('()[]{}<>')])
        x_op = ''.join([p for i in xrange(l / 2) for p in random.choice('([{<')])
        x = x_op + x
        result += t.timeit(number=1000)
    print('n={1:5d}\ttime={0:8.6f}'.format(result / 100, l))
